function addTea() {
    //获取添加页面中的茶叶信息

    let teaName = document.getElementById("teaName").value;

    let teaPrice = document.getElementById("teaPrice").value;

    let teaSelect = document.getElementById("teaClass");

    let optionList = teaSelect.getElementsByTagName("option");

    let teaClass;

    for (let i in optionList) {
        if (optionList[i].selected) {
            teaClass = i;
        }
    }

    let teaDescrible = document.getElementById("teaDescrible").value;

    let teaImg = getValue();

    //创建茶叶对象
    let tea = new Tea(1,teaName,teaPrice,teaClass,teaDescrible,teaImg);

    //发送ajax请求
    $.ajax({
        type:"post",
        url:"/js/addTea",
        data:JSON.stringify(tea),
        dataType:"json",
        success:function(data){
            if(data){
                alert("添加成功!")
                location.reload();
            }else{
                alert("添加失败!")
            }
        }
    })

}

function getValue() {

    let file = document.getElementById("fileInput");

    let fileObj = file.files;

    let returnValue;

    returnValue = fileObj[0].name;

    document.getElementById("teaPir").innerHTML = `<img src="../../img/${returnValue}"  style="width: 80px; height: 80px;">`;

    return returnValue;

}